import Vue from 'vue'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios';
import router from './router.js';
import App from './App.vue'
import './styles/common.scss'
import VideoPlayer from 'vue-video-player'
import 'video.js/dist/video-js.css'
import 'vue-video-player/src/custom-theme.css'
import 'videojs-flash'
import 'videojs-contrib-hls'
import VueAMap from 'vue-amap';
import '@/mock/'
import './config'
//注册自定义组件
import './components/'
//导入主题文件
import '@/theme/index.js'

window.axios = axios;
Vue.config.productionTip = false;
Vue.prototype.url = window.requestUrl;
Vue.use(window.AVUE, {
  size: 'mini'
});
Vue.use(ElementUI);
Vue.use(VideoPlayer)
Vue.use(VueAMap);
// 初始化vue-amap
VueAMap.initAMapApiLoader({
  key: '2142e4296d539368ef176a9d60eee9bc',
  plugin: [],
  v: '1.4.15',
  uiVersion: '1.1'
});

//http request 拦截器
axios.interceptors.request.use(
  config => {
    if (localStorage.getItem('x-access-token')) {
      config.headers = {
        "X-Access-Token": localStorage.getItem('x-access-token')
      }
    }
    return config;
  },
  error => {
    return Promise.reject(error)
  }
)

axios.interceptors.response.use(
  response => {
    return response;
  },
  error => {
    return Promise.reject(error.response)
  }
)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
